import React from 'react';
import ReactDOM from 'react-dom';

import Bannerlist from './Bannerlist'


// 用户视角
class App extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      lists: ['item1', 'item2','item3','item4','item1'],
      currentIndex: 0
    }
  }
  move() {
    this.setState({
      currentIndex: this.state.currentIndex+1
    })
  }
  animation() {
    setInterval(() => {
      this.move()
    }, 2000);
  }
  componentDidMount() {
    this.animation()
  }
  render() {
    return (
      <>
        <Bannerlist
          lists={this.state.lists}
          cur={this.state.currentIndex}
          onEnd = {(n)=>{this.setState({currentIndex: n})}}
        ></Bannerlist>
      </>
    )
  }
}


ReactDOM.render(<App />, document.getElementById('root'));